package com.flux.tms.tm${bean.numMain}srv.t${bean.numMain}${bean.numSub}.impl.dao;

import static org.mockito.ArgumentMatchers.any;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.mockito.InjectMocks;
import org.powermock.api.mockito.PowerMockito;
import org.testng.annotations.Test;

import com.alibaba.druid.util.JdbcConstants;
import com.flux.tms.tm${bean.numMain}srv.common.dao.CommonDao;
import com.flux.wmsv5.comobjs.LoginInfoObj;

public class ${bean.fileName}Test extends CommonDao{
    @InjectMocks
    private ${bean.fileName} ${bean.fileName};
    
    @Test
    public void test() throws Exception {
        initLogin();
        initBizDataMap();
        ${bean.fileName} spy = PowerMockito.spy(${bean.fileName});
<#assign hasErr=false>
<#assign hasNomal=false>
<#if (bean.methods)?size !=0>
         <#list (bean.methods)! as method>
            <#if (method.nName)?contains("insert")||(method.nName)?contains("update")||(method.nName)?contains("del")>
                <#if (method.nName)?contains("insert") >
                PowerMockito.doReturn(1).when(spy, "insertRow",any(LoginInfoObj.class), any(),any());
                </#if>
                <#if (method.nName)?contains("update") >
                    PowerMockito.doReturn(1).when(spy, "editRow",any(LoginInfoObj.class), any(),any());
                </#if>
                <#if (method.nName)?contains("del") >
                    PowerMockito.doReturn(1).when(spy, "deleteRow",any(LoginInfoObj.class), any(),any());
                </#if>
                spy.${method.mName}(loginInfoObj, bizDataMap);
            <#else >
                <#if hasErr!=true>
                    PowerMockito.doReturn(new HashMap<String, Object>()).when(spy, "queryForMap",any(LoginInfoObj.class), any(String.class),any(List.class),any(Boolean.class));
                    <#assign hasErr=true>
                </#if>
                PowerMockito.doReturn(new HashMap<String, Object>()).when(spy, "queryForMap",any(LoginInfoObj.class), any(String.class),any(List.class),any(Boolean.class));
                spy.${method.mName}(loginInfoObj, bizDataMap);
            </#if>

    </#list>
    <#list (bean.methods)! as method>
        <#if (method.nName)?contains("insert")||(method.nName)?contains("update")||(method.nName)?contains("del") >
        <#else >
            <#if hasNomal!=true>
                PowerMockito.doThrow(exception).when(spy, "queryForMap",any(LoginInfoObj.class), any(String.class),any(List.class),any(Boolean.class));
                <#assign hasNomal=true>
            </#if>
           spy.${method.mName}(loginInfoObj, bizDataMap);
        </#if>

    </#list>
</#if>
        <#--PowerMockito.doReturn(1).when(spy, "insertRow",any(LoginInfoObj.class), any(),any());-->
        <#--//        spy.insertAsnDocFee1H(loginInfoObj, bizDataMap);-->
        <#--spy.insertRulDisZoneArea1H(loginInfoObj, bizDataMap);-->
        <#--PowerMockito.doReturn("1").when(spy, "isnull",any(String.class),any(Integer.class));-->
        <#--PowerMockito.doReturn(dbhelper).when(spy, "getDbHelper");-->
        <#--PowerMockito.doReturn(JdbcConstants.MYSQL).when(spy, "getDbType");-->
        <#--Map<String,String> tmpMapList = new HashMap<String, String>();-->
        <#--Map<String,String> tmpMap = new HashMap<String, String>();-->
        <#--PowerMockito.doReturn(tmpMap).when(spy, "queryForMap",any(LoginInfoObj.class),any(String.class),any(List.class),any(Boolean.class));-->
        <#--PowerMockito.doReturn(tmpMapList).when(spy, "queryForList",any(LoginInfoObj.class),any(String.class),any(List.class),any(Boolean.class));-->
        <#--PowerMockito.doReturn(1).when(spy, "insertRow",any(LoginInfoObj.class),any(Map.class),any(String.class));-->
        <#--PowerMockito.doReturn(1).when(spy, "deleteRow",any(LoginInfoObj.class),any(String.class),any(LinkedHashMap.class));-->
        <#--PowerMockito.doReturn(1).when(spy, "editRow",any(LoginInfoObj.class),any(Map.class),any(String.class),any(LinkedHashMap.class));-->
        <#--PowerMockito.doReturn(1).when(spy, "update",any(LoginInfoObj.class),any(String.class),any(Object[].class));-->

    }
    
    @Override
    protected CommonDao returnSubClass() {
        return this;
    }

    @Override
    protected void initSubLogin() {
        
    }

    @Override
    protected void initSubBizDataMap() {
        
    }
    
    
}
